//
//  CustomTableViewCell.m
//  UI11_homework_通讯录
//
//  Created by aaaaaa on 16/6/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "Contant.h"

#define kHeight self.contentView.frame.size.height
#define kWidth self.contentView.frame.size.width

@interface CustomTableViewCell ()

@property (nonatomic, retain) UIImageView *contantImageView;
@property (nonatomic, retain) UILabel *nameLable;
@property (nonatomic, retain) UILabel *numberLable;

@end


@implementation CustomTableViewCell

- (void)dealloc
{
    [_contant release];
    [_contantImageView release];
    [_nameLable release];
    [_numberLable release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _contantImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_contantImageView];
        [_contantImageView release];
        
        _nameLable = [[UILabel alloc] init];
        [self.contentView addSubview:_nameLable];
        [_nameLable release];
        
        _numberLable = [[UILabel alloc] init];
        [self.contentView addSubview:_numberLable];
        [_numberLable release];
        
     }
    
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    
    self.contantImageView.frame = CGRectMake(10, 10, kHeight - 20, kHeight - 20);
//    self.contantImageView.backgroundColor = [UIColor orangeColor];
    self.contantImageView.layer.cornerRadius = (kHeight - 20) / 2;
    self.contantImageView.layer.masksToBounds = YES;
    
    self.nameLable.frame = CGRectMake(kWidth * 0.4, 15, kWidth * 0.55, kHeight * 0.3);
//    self.nameLable.backgroundColor = [UIColor grayColor];
    
    self.numberLable.frame = CGRectMake(kWidth * 0.4, kHeight * 0.55, kWidth * 0.55, kHeight * 0.3);
//    self.numberLable.backgroundColor = [UIColor lightGrayColor];
    
}

- (void)setContant:(Contant *)contant{
    if (_contant != contant) {
        [_contant release];
        _contant = [_contant retain];
    }
    
    self.nameLable.text = contant.name;
    self.numberLable.text = contant.number;
    self.contantImageView.image = [UIImage imageNamed:contant.header];
    
    
}














@end
